package com.example.demo;


import org.apache.commons.lang3.StringUtils;

public class BaseRowData implements Comparable<BaseRowData> {

    private String name;

    private int column;

    private int mergeColumn = 0;

    private int mergeRow = 0;

    private int startRow = 1;

    private Short height;

    public BaseRowData setHeight(Short height) {
        this.height = height;
        return this;
    }

    public Short getHeight() {
        return height;
    }

    public BaseRowData setStartRow(int startRow) {
        this.startRow = startRow;
        return this;
    }

    public int getExRow() {
        return startRow - 1;
    }


    public int getExColumn() {
        return getColumn() - 1;
    }

    public BaseRowData setColumn(int column) {
        this.column = column;
        return this;
    }

    public boolean needMergeColumn() {
        return mergeColumn > 0;
    }

    public boolean needMergeRow() {
        return mergeRow > 0;
    }

    public BaseRowData(String name, int column) {
        this(name);
        this.column = column;
    }

    public BaseRowData(String name) {
        this.name = StringUtils.isBlank(name) ? StringUtils.EMPTY : name;
    }

    public BaseRowData(String name, int column, int mergeColumn) {
        this(name);
        this.column = column;
        this.mergeColumn = mergeColumn;
    }

    public int getMergeRow() {
        return mergeRow;
    }

    public BaseRowData setMergeRow(int mergeRow) {
        this.mergeRow = mergeRow;
        return this;
    }

    public int getColumn() {
        return column;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getMergeColumn() {
        return mergeColumn;
    }

    public void setMergeColumn(int mergeColumn) {
        this.mergeColumn = mergeColumn;
    }

    @Override
    public int compareTo(BaseRowData o) {
        return Integer.compare(column, o.column);
    }
}